import path from "path"
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
//
import Unocss from "unocss/vite";
import presetMini from "@unocss/preset-mini";
import presetIcons from '@unocss/preset-icons'
// https://vitejs.dev/config/
export default defineConfig({
  resolve: {
    alias: {
      '@': path.resolve(__dirname, './src'),
      'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js',
    },
  },
  plugins: [
    vue(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
      symbolId: "icon-[dir]-[name]",
      inject: "body-last",
      customDomId: "__svg__icons__dom__",
    }),
    Unocss({
      presets: [presetMini(),presetIcons()],
      //
      variants: [
        (matcher) => {
          // 支持 hover-items 样式
          if (!matcher.startsWith("hi:")) return matcher;
          return {
            matcher: matcher.slice(3),
            selector: (s) =>
              `.hover-items:hover ${s.replace(/^(\W)?hi\\?\:/gi, "$1")}`,
          };
        },
      ],
      rules:[
        // ['fs-(.*)',{}]
      ]
    }),
  ]
})
